
/**
 * api接口统一管理
 */

import store from '../vuex/store.js';
import { get, post,postFormData,getfile} from './http'

const has_zyyp = () => {
    if (store.state.switchHeadTab =='生产系统') {
        return ''
    }else {
        return 'ZYYP'
    }
}

export const login = p => post('pellet/login', p);//保存 post方法
export const updatepwd = p => post('/user/updatePwd',p)
// 通用
export const materialBreed_findAll = p => get('materialBreed/findAll', p); //物料信息(包括品名等)
export const user_findAll = p => get('user/findByAll', p); //用户列表
export const technology_findByAll = p => get('technology/findByAll',p); // 工艺下拉列表
export const supplier_findByAll = p => get('supplier/findByAll',p); // 供应商列表

// 登录验证
export const login_getnum = p => get('geetest/randomNum',p);
export const login_verify = p => get('geetest/register',p); //
export const login_validate = p => postFormData('geetest/validate',p); //

// 首页
export const home_findByMaterial = p => get('/home/findByMaterial',p); // 原料入库
export const home_findByManufacture = p => get('/home/findByManufacture',p); // 生产管理
export const home_findByDetection = p => get('/home/findByDetection',p); // 检测管理
export const home_findByPack = p => get('/home/findByPack',p); // 颗粒包装 分包管理
export const home_findByPrint = p => get('/home/findByPrint',p); // 打印管理  审核管理
export const home_statistics = p => get('/home/statistics',p); //统计概况
export const home_findByMessage = p => get('/home/findByMessage',p); // 消息中心
export const home_scan = p => get('/home/scan',p); // 扫码统计
export const home_scanSource = p => get('/home/scanSource',p); // 扫码来源

//客户管理
export const client_findByList = p => post('client/findByList', p);//列表
export const client_save = p => post('client/save', p);//新增
export const client_update = p => post('client/update', p);//修改
export const client_findById = p => get('client/findById/',p);//根据id查询
export const client_delete = p => get('client/delete/', p);//根据id删除
export const client_daoru = p => postFormData('client/excel', p);

// 原料入库
export const material_findByList = p => post('material/findByList',p); //列表
export const material_save = p => post('material/save',p); //添加原料
export const material_findById = p => get('material/findById/',p);  //查看原料信息
export const material_update = p => post('material/update/',p); //修改原料
export const material_existBatch = p => post('material/existBatch',p); //判断批次号是否重复

// 原料入库的批次入库
export const receive_search = p => get('http://zz.xinlvyao.com:8902/receive/search/',p);  //通过溯源码查询
// export const receive_search = p => get('http://lszz.yenlien.com/receive/search/',p);  //通过溯源码查询

// 报损
export const loss_save = p => post('loss/save',p); //添加原料

// 库存管理
export const warehouse_findList = p => post('warehouse/findList',p); // 库存列表

export const warehouse_save = p => post('warehouse/save',p); // 新增仓库
export const warehouse_export = p => post('warehouse/export',p); // 导出仓库数据
export const warehouse_findByList = p => post('warehouse/findByList',p); // 仓库列表
export const warehouse_isStart = p => post('warehouse/isStart',p); // 修改状态
export const warehouse_update = p => post('warehouse/update',p); // 修改仓库
export const warehouse_findById = p => post('warehouse/findById/',p); // 查看仓库
export const warehouse_findByWarehouseId = p => get('warehouse/findByWarehouseId/',p); // 修改仓库查看
export const warehouse_deleteById = p => get('warehouse/deleteById/',p); // 删除仓库
export const warehouse_findAll = p => get('warehouse/findAll',p); // 仓库下拉列表

// 生产管理
export const manufacture_findByList = p => post('manufacture/findByList',p); //列表
export const manufacture_findByAllMaterType = p => post('materialBreed/findAllByMaterialType',p); //品名根据类型下拉列表
export const warehouse_findBreedName = p => post('warehouse/findBreedName',p); //原料辅料品名下拉列表
export const warehouse_findBatchByBreedName = p => post('warehouse/findBatchByBreedName',p); //原料辅料入库批次下拉列表
export const manufacture_save = p => postFormData('manufacture/save',p); //新增生产
export const manufacture_findById = p => get('manufacture/findById/',p); //查看生产
export const manufacture_update = p => postFormData('manufacture/update',p); //编辑生产
export const manufacture_adjust = p => post('manufacture/adjust',p); // 调整产量
export const technology_findByType = p => post('technology/findByType',p)// 根据产品类型查看工艺列表
export const manufacture_existBatch = p => post('manufacture/existBatch',p); // 判断生产批号重复
export const findBreedNameBySearch = p =>post("warehouse/findBreedNameBySearch",p)


export const getcode = p =>get("/materialBreed/getMaterialCode?breedName=",p)  //根据名称获取物料代码
export const getspecscode = p =>get("/materialBreed/getSpecsCode?breedName=",p)  //根据名称获取规格码


export const findQualityStandard = p =>get("/material/findQualityStandard?breedName=",p)  //根据名称和批号获取质量标准
// 检测管理
export const detection_findByList = p => post('detection/findByList',p); // 检测列表
export const check_findByAll = p => get('check/findByAll',p);  //检测依据下拉列表
export const detection_save = p => postFormData('detection/save',p);  //添加检测
export const detection_findByRelevanceId = p => post('detection/findByRelevanceId',p);  //查看检测
export const detection_update = p => postFormData('detection/update',p);  //编辑检测
export const detection_down = p => get('detection/download/',p)

export const check_findByName = p => get("/check/findByName",p)


// 颗粒包装
export const pack_findByList = p => post('pack/findByList',p); //列表 也是 分包列表
export const pack_save = p => post('pack/save',p); //新增包装
export const pack_findPackBreedName = p => post('pack/findPackBreedName',p); //品名根据类型下拉列表
export const pack_findMaterialBreedMsg = p => post('pack/findMaterialBreedMsg',p); //根据品名查存货代码
// export const warehouse_findPackBreedName = p => post('warehouse/findPackBreedName',p); //投料列表   引用生产的原料warehouse_findBreedName
// export const pack_findByBreedName = p => post('pack/findByBreedName',p); // 根据投料名查生产批号  引用生产的原料名查批号warehouse_findBatchByBreedName
export const pack_findById = p => get('pack/findById/',p); // 查看
export const pack_adjust = p => post('pack/adjust',p); // 调整产量
export const pack_existBatch = p => post('pack/existBatch',p); // 判断生产批号重复
export const pack_update = p => post('pack/update',p); // 编辑
export const pack_get = p => get('pack/findPrintMsg/',p)

// 分包管理
export const print_save = p => post('print/save',p);  //分包
export const print_findById = p => get('print/findById/',p);  //查看分包里面的生产

// 审核
export const print_findByList = p => post('print/findByList',p);  //审核列表
export const print_isOk = p => post('pack/isOk',p);  //审核

// 打印管理
export const print_findMsg = p => get(`print/findMsg${has_zyyp()}/`,p); //查看分包里面的生产
export const print_send = p => post('print/send',p); // 发送打印
export const print_detail = p => post('print/detail',p); //查看打印
export const print_resend = p => get('print/resend/',p); // 重发送
export const print_sendnum =p => get('print/num/',p)//打印数量
export const getCodeByBatch =(p) => getfile('print/getCodeByBatch?batch='+p,'')//二维码
export const codeText =p => get('print/getBarTextCodeByBatch?batch=',p)//一维码文字



//召回管理
export const recall_findByList = p => post('recall/findByList',p);  //召回列表
export const warehouse_findByType = p => post('warehouse/findByType',p);  //召回批次列表
export const recall_save = p => post('recall/save',p);  // 新增召回
export const recall_findById = p => get('recall/findById/',p);  //查看

// 追溯查询
export const search_getMsg = p => get('search/getMsg/',p); //追溯码查询
export const recall_findByBzBatch = p => post('recall/findByBzBatch/',p); //批号查询

// 单位管理
export const unit_findByList = p => get('/unit/findByAll',p) //获取单位管理列表
export const unit_save = p => post('/unit/saves',p)  //新增和修改接口
export const unit_delete = p => get("unit/delete/",p) //删除
// 条码管理
export const getcodeMsg = p => get("/template/findBarCode",p) //条码信息
export const code_save = p => post('/template/saveBarCode',p)  //修改条码
// 物料管理
export const materialBreed_list = p => post('materialBreed/findByList',p);  //列表
export const materialBreed_save = p => post('materialBreed/save',p);  // 新增物料
export const materialBreed_delete = p => get('materialBreed/deleteById/',p);  // 删除物料
export const materialBreed_findById = p => get('materialBreed/findById/',p);  //查看物料信息
export const materialBreed_update = p => post('materialBreed/update/', p); //修改物料
export const materialBreed_isExist = p => get('materialBreed/checkMaterialCodeIsExist',p); // 验证物料编码
export const materialBreed_inmaterial = p => postFormData('materialBreed/inMaterialBreed',p); // 导入模板
export const materialBreed_updateStatus = p => post('materialBreed/updateStatus', p);  // 修改状态（启用、禁用）

export const mater_daoru = p => postFormData('/materialBreed/importManually',p)


export const materialBreed_findInventoryCodeIsExist = p =>get('materialBreed/findInventoryCodeIsExist/',p)//判断 存货代码是否重复

//工艺工序
export const process_list = p => post('technology/findByList',p);  //列表
export const process_save = p => post('technology/save',p);   //保存
export const process_update = p => post('technology/update',p);   //修改
export const process_delete = p => get('technology/delete/',p); //删除
export const process_findById = p => get('technology/findById/',p); //编辑查询
export const process_daoru = p => postFormData('technology/excel',p)//导入模板

// 检测依据
export const check_list = p => post('check/findByList',p);  //列表
export const check_save = p => postFormData('check/save',p);  //保存
export const check_delete = p => get('check/delete/',p); // 删除
export const check_findById = p => get('check/findById/',p); //编辑查询
export const check_update = p => postFormData('check/update',p); //修改
export const check_add = p => postFormData('check/add',p)

// 供应商管理
export const supplier_list = p => post('supplier/findByList',p);  //列表
export const supplier_save = p => post('supplier/save',p);  //保存
export const supplier_delete = p => get('supplier/delete/',p); // 删除
export const supplier_findById = p => get('supplier/findById/',p); //编辑查询
export const supplier_update = p => post('supplier/update',p); //修改
export const supplier_checklist = p => get('material/findBySupplyId/',p);
export const supplier_daoru = p => postFormData('supplier/excel',p); //修改

// 员工管理
export const staff = p => post('department/save',p);
export const staff_findById = p => get('department/findByCompanyId/',p);
export const staff_getId = p => get('department/findByParentId/',p);
export const staff_save = p => post('department/save',p);
export const staff_update = p => post('department/update',p);
export const staff_getfindById = p => get('department/findById/',p);
export const staff_delete = p => get('department/delete/',p);


export const staffuser_save = p => postFormData('user/save',p);
export const staffuser_findByList = p => post('user/findByList',p);
export const staffuser_delete = p => get('user/delete/',p);
export const staffuser_update = p => postFormData('user/update',p);
export const staffuser_findById = p => get('user/findById/',p);
export const staffuser_findByAll = p => get('department/findByAll',p);
export const staffuser_daoru = p => postFormData('user/excel',p);

// 组织架构


// 企业信息
export const company_update = p => postFormData('company/update',p); // 修改
export const company_findById = p => get('company/getById/',p); //获取企业信息


//权限配置
export const jurisdiction = p => get('menu/findByAll',p); // 获取
export const jurisdiction_saveMenu = p => post('department/saveMenu',p); // 部门保存
export const jurisdiction_saveuser = p => post('user/saveMenu',p);
export const jurisdiction_getMenu = p => get('department/findByMenu/',p); // 部门权限获取
export const jurisdiction_staff = p => get('user/findByAll',p); // 所有人员
export const jurisdiction_user = p => get('user/findByUserMenu/',p); //

//产品信息
export const product_findmater = p => post('materialBreed/findAllByMaterialType',p);
export const product_findbreed = p => post('materialBreed/findByBreedName',p);
export const product_save = p => postFormData('product/save',p);
export const product_findByList = p => post('product/findByList',p);
export const product_findById = p => get('product/findById/',p);
export const product_update = p => postFormData('product/update',p);
export const product_delete = p => get('product/delete/',p);



//权限管理

export const permission_save = p => post('menu/save',p);
export const permission_delete = p => get('menu/delete/',p);


// 系统日志
export const system_list = p => post('system/log/findByList',p)

// 消息
export const message_list = p => post('message/findByList',p)
export const message_update = p =>post('message/update',p)
export const message_getmessage = p =>get('message/getMessage/',p)
export const message_updateAll = p =>get('message/updateAll/',p)

//订单 管理   数据发送

export const order_findByList = p => post('order/findByList',p)
export const packbatch_list = p => get('print/findByBatchAll',p)
export const client_findByAll = p => get('client/findByAll',p)
export const order_save = p => post('order/save',p) //单次发送
export const order_saves = p => postFormData("order/save2",p)//批次发送


// 检测机构
export const manage_save = p => post("/check/manage/save",p)
export const manage_findByList = p => post("check/manage/findByList",p)
export const manage_update = p => post("check/manage/update",p)
export const manage_delete = p => get("check/manage/delete/",p)
export const manage_findById = p => get("check/manage/findById/",p)
export const manage_findByAll = p => get("check/manage/findByAll",p)


export const template_save = p => post("/template/save",p)
export const template_get = p => get("/template/findByType",p)


// 供货管理
export const supply_findByList = p => post("/supply/findByList",p)
export const supply_save = p => postFormData("/supply/save",p)
export const supply_findByDetailedList = p => post("/supply/findByDetailedList",p)
export const supply_findbreed = p => get("/order/findByBreedName",p)
export const supply_findbatch = p => post("/order/findByBatch",p)
export const supply_update = p => post("/supply/updateDetailed",p)
export const supply_export = p=> get("/supply/export/",p)
export const ceshi = p => postFormData('company/add',p);
export const send_export = p => getfile("/order/out",p)
export const getAddressByBatch = p => get("/material/getAddressByBatch?inBatch=",p)
export const sgetAddressByBatch = p => get("/manufacture/getAddressByBatch?batch=",p)

//增加打印量
export const addPrintNumber = p => post("/print//update",p)

//首页
export const homegetallfactory = p =>get("/homeNew/getAllFactory",p)//获取所有厂区
export const homegetproddata = p => get("/homeNew/getProdData?companyId=",p)//生产统计数据
export const homegetdata = p => post("/homeNew/getHistogramData",p)
export const homegetrankdata = p => post("/homeNew/getRankData",p)
export const homegetpointdata = p => post("homeNew/getPointData",p)
export const homegetpiedata = p =>post("/homeNew/getPieData",p)
export const homelinklist = p => post("/homeNew/findList",p)
export const hometrace = p => get("/homeNew/trace?id=",p)

export const downTemplate = p => get("/check/downTemplate",p)
export const check_daoru = p => postFormData('/check/import2',p)//导入模板

export const importSellRecord = p => get("/materialBreed/importSellRecord",p)
export const exportSellRecordTemp = p => postFormData('/materialBreed/importSellRecord',p)//导入模板


export const getProd = p => get("/homeNew/getProd?",p)

export const getCodeData = p => get("/homeNew/getCodeData?companyId=",p)

export const uploadFiles = data =>postFormData('/file/upload2',data)

export const complianceRate = data => post('/detection/complianceRate',data)

export const selectProductStorageList = data =>post('/pack/getFinishedProdInLit',data)

export const selectStoragedProductById = query =>get('/pack/getFinishedProdInById',query)

export const getPushData = data=>post('/pack/getPush',data)

export const pushKANGSEProduct = data => post('/pack/pushFinishedProdIn',data)

//切换系统
export const switchSystem = query => get('/system/log/switchSysType?sysType=',query)

//查询生产许可证
export const getProdLicense = query => get('/search/getAllProdLicense',query)

//修改/新增生产许可证
export const updateOrAddProdLicense = data => post('/search/saveProdLicense',data)
